{include file="public/header" /}</head>
<body class="layui-anim">
<div class="x-nav layui-row">
	<span class="layui-breadcrumb layui-col-md9 layui-col-sm9">
		<a href="javascript:;">{$_page_navi.1.title}</a>
		<!-- {if $_page_navi.0}<a href="javascript:;">{$_page_navi.0.NavName}</a>{/if}
		{if $_page_navi.1}<a><cite>{$_page_navi.1.NavName}</cite></a>{/if} -->
	</span>
	<!-- <a class="layui-btn layui-btn-small" style="float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon">&#xe9aa;</i></a> -->
</div>
<div class="x-body">
	<blockquote class="layui-elem-quote layui-clear " style="padding: 5px;line-height: 38px;">
		<span style="font-size: 16px;"><i class="layui-icon">&#xe653;</i>&nbsp;{$_page_navi.1.NavName}</span>
		<form class="layui-form layui-col-md8 x-so layui-form-pane x-right" style="margin: 0;text-align: right;">
			<input class="layui-input date_range" placeholder="建团/开团时间" name="times" value="{$Request.param.times}" style="width: 20%"/>
			<!-- <div class="layui-input-inline">
				<select name="group_cate_id">
					<option value="" >拼团级别</option>
					<option value="1" {if $Request.param.group_cate_id == 1}selected{/if}>1级拼团</option>
					<option value="2" {if $Request.param.group_cate_id == 2}selected{/if}>2级拼团</option>

				</select>
			</div> -->
			<!-- <div class="layui-input-inline">
				<select name="state">
					<option value="" >状态</option>
					<option value="1" {if $Request.param.state == 1}selected{/if}>待开团</option>
					<option value="2" {if $Request.param.state == 2}selected{/if}>已开团</option>

				</select>
			</div> -->
			<button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
			{if $Request.param.times || $Request.param.group_cate_id || $Request.param.state}
			<a href="{:url('Collage/index')}" class="layui-btn layui-bg-blue">撤销搜索</a>
			{/if}
		</form>
	</blockquote>
	<xblock>
		<!-- {foreach name="cate" item="vo" }
		<button class="layui-btn layui-btn-normal" onclick="add_robot('{$vo.id}');">
			<i class="layui-icon"></i>添加{$vo.id}级拼团机器人
		</button>
		{/foreach} -->
		<!-- <button class="layui-btn layui-btn-danger" onclick="fenhong_all(1);">
			<i class="layui-icon"></i>周结
		</button>
		 -->
		<button class="layui-btn layui-btn-danger" onclick="open_group(4);">
			<i class="layui-icon"></i>初始化
		</button>
	<!-- 	<button class="layui-btn layui-btn-danger" onclick="open_group(1);">
			<i class="layui-icon"></i>开团
		</button>
		<button class="layui-btn layui-btn-danger" onclick="over();">
			<i class="layui-icon"></i>检测超时
		</button> -->
		<span class="x-right" style="line-height:40px">共有数据：{$list->total()} 条</span>
	</xblock>
	<table class="layui-table layui-form">
		<thead>
		<tr>
			<th>团ID</th>

			<th>编号</th>
			<th>拼团商品</th>
			<th>建团时间</th>
			<th>开团时间</th>
			<!-- <th>开奖时间</th> -->
			<!-- <th>参与人数</th> -->
			<th>团内人数</th>
			<!-- <th>新增业绩</th> -->
			<!-- <th>拼团成功人数</th> -->
			<!-- <th>拼团失败人数</th> -->
			<!-- <th>下次开团时间</th> -->
			<!-- <th width="80px">状态</th> -->
			<!-- <th width="80px">是否发奖</th> -->
<!--			<th>操作</th>-->
		</tr>
		</thead>
		<tbody>
		{volist name="list" id="v"}
		<tr class="data_line" data_id="{$v.id}">
			<td>{$v.id}</td>
			<td>{$v.number}</td>
			<td>{$v.title}</td>
			<td>{:date('Y-m-d H:i:s',$v.create_time)}</td>
			<td>
				{if $v.update_time}
				{:date('Y-m-d H:i:s',$v.update_time)}
				{else}
				 -
				{/if}
			</td>
			<td>
				<a onclick="show('当前团内人数','{:url(\'order/group_info\',[\'oid_arr\'=>$v.oid_arr])}',3000,3000)" href="javascript:;">点击查看</a>
			</td>
			<!-- <td>
				<a onclick="zhiju_show('拼团成功人数','{:url(\'GroupOrder/index\',[\'id\'=>$v.id,\'state\'=>2])}',3000,3000)" href="javascript:;">点击查看</a>
			</td>
			<td>
				<a onclick="zhiju_show('拼团失败人数','{:url(\'GroupOrder/index\',[\'id\'=>$v.id,\'state\'=>3])}',3000,3000)" href="javascript:;">点击查看</a>
			</td> -->
		<!-- 	<td>
				{if $v.next_time}
				{:date('Y-m-d H:i:s',$v.next_time)}
				{else}
				-
				{/if}
			</td> -->
			<!-- <td>
				{$v.state==1?'待开团':'已开团'}
			</td>
			<td>
				{$v.is_give==0?'未开奖':'已开奖'}
			</td> -->
<!--			<td class="td-manage">-->
<!--				<div class="layui-btn-group">-->
<!--					<a class="layui-btn layui-btn-sm" onclick="zhiju_show('查看','{:URL(request()->controller().'/info',['id'=>$v.number])}',600,900)" href="javascript:;">查看</a>-->
<!--				</div>-->
<!--			</td>-->
		</tr>
		{/volist}
		</tbody>
	</table>
	<div class="page"><div>{$list->render()}</div></div>
</div>
</body>
<script>
	function open_group(type) {
		var name;
		switch (type) {
			case 1:
				name = '所有等级的拼团将会直接开团，仅限测试使用，是否继续？';
				break;
			case 2:
				name = '处理开团后中奖用户逻辑，仅限测试使用，是否继续？';
				break;
			case 3:
				name = '处理开团后未中奖用户逻辑，仅限测试使用，是否继续？';
				break;
			case 4:
				name = '清除所有记录，仅限测试使用，是否继续？';
				break;

		}
		layer.confirm(name, {title:'请确认'}, function(){
			layer.load(2);
			$.ajax({
				type: 'GET',
				url: '{:url("Collage/open_group")}',
				data: {type:type,t_id:11},
				dataType: "json",
				success: function (data) {
					layer.closeAll();
					if(data.code == 1){
						layer.msg(data.msg,{time:1500},function () {
							location.reload();
						});
					}else{
						layer.msg(data.msg);
					}
				}
			});
		});
	}
	function over(argument) {
		layer.confirm('仅测试使用', {title:'请确认'}, function(){
		layer.load(2);
		$.ajax({
			type: 'GET',
			url: '{:url("Collage/check_g_over")}',
			data: {},
			dataType: "json",
			success: function (data) {
				layer.closeAll();
				if(data.code == 1){
					layer.msg(data.msg,{time:1500},function () {
						location.reload();
					});
				}else{
					layer.msg(data.msg);
				}
			}
		});
		});
	}
	
	function add_robot(id) {
		layer.alert('您正在添加'+id+'级拼团机器人:<br/><span style="color: red">1.添加的机器人仅对当前暂未开的团有效，开后即焚</span>' +
				'<br/>2.单次添加数不得超500个,如需添加更多请分批',{title:'添加机器人须知'},function () {
			layer.prompt({title: '请输入要添加的数量', formType: 3}, function(pass, index){
				layer.close(index);
				layer.confirm('确认要添加吗？', {title:'请确认'}, function(){
					layer.load(2);
					 $.ajax({
						 type: 'GET',
						 url: '{:url("Collage/add_robot")}',
						 data: {id:id,num:pass},
						 dataType: "json",
						 success: function (data) {
						 	layer.closeAll();
							if(data.code == 1){
								layer.msg(data.msg,{time:1000},function () {
									location.reload();
								});
							}else{
								layer.msg(data.msg);
							}
						 }
					 });
				});
			});
		});
	}
	function fenhong_all(type) {
          layer.confirm('确认要发放吗？',function(index){
            let plode=layer.load(2);
            //捉到所有被选中的，发异步进行删除
            $.get("{:URL('Release/release_all')}",{type:1},function(data){
              if (data.code==1) {
                /*  if (type == "删除") {
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                  }*/
                  layer.msg(data.message,{icon:1,time:1000},function () {
                    location.reload();
                  });
              } else {
                  layer.msg(data.message,{icon:1,time:1000});
                  layer.close(plode);
                    // location.reload();

              }
            });
          });
    }
        
</script>
</html>